<template>
  <view v-if="isLoad" v-show="showGLoading" class="d-loading-container">
    <view class="d-loading">
<!--      <view class="loading-header-bg"></view>-->
      <view class="loading-body flex flex-column justify-center">
        <view class="loading-logo-box">
          <view class="logo flex justify-center align-center">
            <image class="logo-image" :src="logoSvg"></image>
          </view>
          <view class="sys-name-zh mt2.5">华信管理平台</view>
          <view class="sys-name-en">HUAXIN MANAGEMENT PLATFORM</view>
        </view>
      </view>
<!--      <view class="loading-footer-bg"></view>-->
    </view>
  </view>
</template>

<script setup lang="ts">
import logoSvg from '@/static/logo.svg'
import {generateUUIDv4} from "@/utils";
import {storeToRefs} from "pinia";
import {useAppStore} from "@/stores";

defineOptions({
  name: 'DLoading',
  // 微信小程序中 options 选项
})

const componentId = generateUUIDv4()
const isLoad = ref<boolean>(false);
const {gLoadingId, showGLoading} = storeToRefs(useAppStore());

onLoad(() => {
  if (!gLoadingId.value) {
    isLoad.value = true;
    gLoadingId.value = componentId;
  }
})
</script>

<style scoped lang="scss">
.d-loading-container {
  background-color: rgba(255, 255, 255, 1);
  position: absolute;
  width: 100%;
  height: 100%;
  top: 0;
  left: 0;
  z-index: 9999;

  .d-loading {
    position: relative;
    width: 100%;
    height: 100%;
    background-color: transparent;
  }

  .loading-body {
    width: 100%;
    height: 100%;
    max-width: 1200px;
    margin: 0 auto;
    position: relative;
    overflow: hidden;
    z-index: 9;

    .loading-form-box {
      padding: 0 20rpx;

      .loading-btn {
        height: 80rpx;
        line-height: 80rpx;
        border-radius: 16rpx;
      }
    }
  }
}

.loading-auth-image {
  width: 120px;
  height: 100%;
}

/*.loading-header-bg {
  position: absolute;
  top: 0;
  left: 0;
  background-image: url("/static/images/passkey/header-bg.png");
  background-repeat: no-repeat;
  background-size: 100% auto;
  z-index: 99;
  width: 100%;
  height: 100%;
}

.loading-footer-bg {
  position: absolute;
  bottom: 0;
  left: 0;
  background-image: url("/static/images/passkey/footer-bg.png");
  background-repeat: no-repeat;
  background-size: 100% auto;
  background-position: bottom;
  z-index: 99;
  width: 100%;
  height: 100%;
}*/

.logo {
  margin: 0 auto;
  width: 160rpx;
  height: 160rpx;
  border-radius: 50%;
  background: linear-gradient(180deg, #CCEDFF 0%, rgba(255, 255, 255, 0) 74%);
  position: relative;
  z-index: 9;

  box-sizing: border-box;
  border: 4rpx solid #fff;
  box-shadow: 0 0 10rpx 10rpx rgba(0, 0, 0, 0.1);

  .logo-image {
    width: 96rpx;
    height: 96rpx;
    //animation-name: rotateSpan;
    //animation-duration: 2s;
    //animation-iteration-count: infinite;
    //animation-delay: 1s;
  }

  //animation-name: moveSpan;
  //animation-duration: 2s;
  //animation-iteration-count: infinite;
  //animation-delay: 1s;
}

@keyframes rotateSpan {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

@keyframes moveSpan {
  0% {
    transform: translate(0);
  }
  50% {
    transform: translate(500rpx);
  }
  51% {
    transform: translate(-500rpx);
  }
  100% {
    transform: translate(0);
  }
}

.sys-name-zh {
  font-size: 48rpx;
  font-weight: 500;
  line-height: normal;
  text-align: center;
  letter-spacing: 0em;
  color: #231815;
}

.sys-name-en {
  font-size: 18rpx;
  font-weight: 300;
  line-height: normal;
  text-align: center;
  letter-spacing: 0em;

  color: #231815;
}
</style>
